/*
 * cow_test.cpp
 * This file is part of dynad
 *
 * Copyright (C) 2014 - Sebastian Gesemann
 *
 * dynad is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * dynad is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with dynad. If not, see <http://www.gnu.org/licenses/>.
 */

 
#include <iostream>
#include "cow.hpp"

struct base {
	int number;

	virtual void saysomething() const
	{ std::cout<<"hello, i'm a base! My number is "<<number<<"\n"; }
};

struct test : base
{
	test()
	{ std::cout << "test::test()\n"; }
	test(test const&)
	{ std::cout << "test::test(test const&)\n"; }
	test& operator=(test const&)
	{ std::cout << "test::operator=(test const&)\n"; return *this; }
	~test()
	{ std::cout << "test::~test()\n"; }

	void saysomething() const
	{ std::cout<<"hello, i'm a test! My number is "<<number<<"\n"; }
};

int main()
{
	cow<test> x;
	x.write().number = 23;
	cow<base> y = x;
	x.write().number = 42;
	y.read().saysomething();
}
